package com.xinke.module.system.mapper.mail;

import java.util.*;

import com.xinke.component.common.pojo.PageResult;
import com.xinke.component.mybatis.mybatis.core.query.LambdaQueryWrapperExt;
import com.xinke.component.mybatis.mybatis.core.mapper.BaseMapperExt;
import com.xinke.module.system.model.entity.mail.MailLogDO;
import org.apache.ibatis.annotations.Mapper;
import com.xinke.module.system.model.vo.mail.*;

/**
 * 邮件日志 Mapper
 *
 * @author yzx
 */
@Mapper
public interface MailLogMapper extends BaseMapperExt<MailLogDO> {

    default PageResult<MailLogDO> selectPage(MailLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperExt<MailLogDO>()
                .eqIfPresent(MailLogDO::getUserId, reqVO.getUserId())
                .eqIfPresent(MailLogDO::getUserType, reqVO.getUserType())
                .eqIfPresent(MailLogDO::getReceiveMailAddress, reqVO.getReceiveMailAddress())
                .eqIfPresent(MailLogDO::getMailAcctId, reqVO.getMailAcctId())
                .eqIfPresent(MailLogDO::getSendMailAddress, reqVO.getSendMailAddress())
                .eqIfPresent(MailLogDO::getTemplateId, reqVO.getTemplateId())
                .eqIfPresent(MailLogDO::getTemplateCode, reqVO.getTemplateCode())
                .likeIfPresent(MailLogDO::getTemplateNickName, reqVO.getTemplateNickName())
                .eqIfPresent(MailLogDO::getTemplateTitle, reqVO.getTemplateTitle())
                .eqIfPresent(MailLogDO::getTemplateContent, reqVO.getTemplateContent())
                .eqIfPresent(MailLogDO::getTemplateParams, reqVO.getTemplateParams())
                .eqIfPresent(MailLogDO::getSendStatus, reqVO.getSendStatus())
                .betweenIfPresent(MailLogDO::getSendTime, reqVO.getSendTime())
                .eqIfPresent(MailLogDO::getSendMessageId, reqVO.getSendMessageId())
                .eqIfPresent(MailLogDO::getSendException, reqVO.getSendException())
                .orderByDesc(MailLogDO::getLogId));
    }

}